<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <link href="style3.css" rel="stylesheet" type="text/css" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>

        <form id="form" name="form" method="post" action="">
            <?php
            include "functions.php";
            session_start();
            $confid = intval($_GET['conference_id']);
            
            $paperid = intval($_GET['paper_id']);
            $member_id = $_SESSION['member_id'];
            

            $con = mysql_connect("localhost", "root", "");

            if (!$con)
            {

                ('Could not connect:' . mysql_error());
            }
            mysql_select_db("mydb", $con);

            $confName = get_conference_name($confid);
            print "<h1>{$confName}</h1>";
            $paperTitle = get_paper_title($paperid);
            print "<h1>{$paperTitle}</h1>";

            
            echo'Please choose how you would like to review this paper:
                <br> <input id="1" type="radio" name="rev[]" value= "online">Online</input></br>
                <input id="offline" type="radio" name="rev[]" value= "offline">Offline</input>
                </br>
                <input id="go" type="submit" name="go" value="GO" onclick="check()"/>';
//directing to the DownloadFor review page.
            if (isset($_POST['down']))
            {
                header("Location: DownloadForReview.php?id={$_GET['id']}");
            }
            ?>
        </form>
        <input type ="hidden" id="paper" name ="paper" value="<?php echo $_GET['paper_id']; ?>"/>
        <input type ="hidden" id="version" name ="version" value="<?php echo get_latest_version($_GET['paper_id']) ?>"/>
        <input type ="hidden" id="conf" name ="conf" value="<?php echo $_GET['conference_id']; ?>"/>
        <input type="hidden" id="deadline" name="deadline" value="
        <?php
        include 'statics.php';
        $rsResult = rsSelect("*", "conference", array('conference_id=', $_GET['conference_id'], 'AND', 'rev_endDate>', 'E__NOW()'));
        if (mysql_num_rows($rsResult) === 0)
            echo "false";
        else
            echo "true";
        ?>"/>
        <script>
            //this function enables the buttons next to the offline radio button if it was selected.
            //it is called when the button is selected taking the name of the radio which fires the action
            //and the names of the buttons to be enabled.
				
        </script>
        <script>
            function check() {
                if (document.getElementById("1").checked==true && document.getElementById('deadline').value.indexOf("true")!=-1) {
                    document.getElementById("form").target="_blank";
                    document.getElementById("form").action = "startReview.php?version_id="+document.getElementById("version").value+"&conference_id=" +document.getElementById("conf").value;
                    //"startReview.php?id="+document.getElementById("paper").value+"&confid=" +document.getElementById("conf").value;
                    //window.location = "startReview.php?id="+document.getElementById("paper").value+"&confid=" +document.getElementById("conf").value;
                }  
                else if(document.getElementById("1").checked==true && document.getElementById('deadline').value.indexOf("true")==-1)
                {
                    alert('Deadline for reviews is already past');
                    document.getElementById('form').action="";
                }
                // directing to the downloadForReview page with the variables needed to download the pdf
                if (document.getElementById("offline").checked && document.getElementById('deadline').value.indexOf("true")!=-1) {
                    document.form.action = "DownloadForReview.php?id="+document.getElementById("paper").value+"&confid="+document.getElementById("conf").value+"&verid="+document.getElementById("version").value;
                } 
                else if(document.getElementById("offline").checked && document.getElementById('deadline').value.indexOf("true")==-1)
                {
                    alert('Deadline for reviews is already past');
                    document.getElementById('form').action="";
                }
            }
        </script>
        <script>
            $('#go').click (function(){
                if (document.getElementById("offline").checked || document.getElementById("1").checked) {
               
                } 
                else {
                    alert ('no button checked');
                }
            });
        
        </script>
    </body>
</html>